package com.heima.wemedia.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.mapper.WmChannelMapper;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class WmChannelServiceImpl extends ServiceImpl<WmChannelMapper, WmChannel> implements WmChannelService {
    @Override
    public ResponseResult channels() {
        //1.查询
        //List<WmChannel> list = list(Wrappers.<WmChannel>lambdaQuery().eq(WmChannel::getStatus, "1"));//查询启动的频道
        LambdaQueryWrapper<WmChannel> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(WmChannel::getStatus, "1");//查询启动的频道
        wrapper.orderByAsc(WmChannel::getOrd);//按ord字段升序
        List<WmChannel> list = list(wrapper);

        //2.返回
        return ResponseResult.okResult(list);
    }
}
